package com.shanghai.shanghaielectric.UI.refreshView;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.shanghai.shanghaielectric.Model.CapacityCuttingModel;
import com.shanghai.shanghaielectric.Model.ReportDateModel;
import com.shanghai.shanghaielectric.R;

import java.util.List;

import shanghaielectric_lib.Utils.DateUtil;

import static shanghaielectric_lib.Utils.DateUtil.dateToString_yy_MM_dd;


/**
 * Created by wnw on 16-5-26.
 */
public class MyAdapter_capacity_cutting extends RecyclerView.Adapter<RecyclerView.ViewHolder> {


    //定义一个集合，接收从Activity中传递过来的数据和上下文
    private List<CapacityCuttingModel> mList;
    private Context mContext;

    public MyAdapter_capacity_cutting(Context context, List<CapacityCuttingModel> list) {
        this.mContext = context;
        this.mList = list;
    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View layout = LayoutInflater.from(mContext).inflate(R.layout.cutting_item, parent, false);
        return new MyHolder(layout);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        if (holder instanceof MyHolder) {
            long id = mList.get(position).getId();


            ((MyHolder) holder).tv_id.setText(position + 1 + "");
            ((MyHolder) holder).tv_date.setText(dateToString_yy_MM_dd(mList.get(position).getDate()));
//
            ((MyHolder) holder).tv_gb1.setText(DateUtil.dateToString_HH_mm_ss(mList.get(position).getGB_1()));
            ((MyHolder) holder).tv_gb2.setText(DateUtil.dateToString_HH_mm_ss(mList.get(position).getGB_2()));
            ((MyHolder) holder).tv_gb3.setText(DateUtil.dateToString_HH_mm_ss(mList.get(position).getGB_3()));
            ((MyHolder) holder).tv_gb4.setText(DateUtil.dateToString_HH_mm_ss(mList.get(position).getGB_4()));

            ((MyHolder) holder).tv_fb1a.setText(DateUtil.dateToString_HH_mm_ss(mList.get(position).getFB_1_A()));
            ((MyHolder) holder).tv_fb1b.setText(DateUtil.dateToString_HH_mm_ss(mList.get(position).getFB_1_B()));
            ((MyHolder) holder).tv_fb1c.setText(DateUtil.dateToString_HH_mm_ss(mList.get(position).getFB_1_C()));

            ((MyHolder) holder).tv_fb2a.setText(DateUtil.dateToString_HH_mm_ss(mList.get(position).getFB_2_A()));
            ((MyHolder) holder).tv_fb2b.setText(DateUtil.dateToString_HH_mm_ss(mList.get(position).getFB_2_B()));
            ((MyHolder) holder).tv_fb2c.setText(DateUtil.dateToString_HH_mm_ss(mList.get(position).getFB_2_C()));

            ((MyHolder) holder).tv_fb3a.setText(DateUtil.dateToString_HH_mm_ss(mList.get(position).getFB_3_A()));
            ((MyHolder) holder).tv_fb3b.setText(DateUtil.dateToString_HH_mm_ss(mList.get(position).getFB_3_B()));
            ((MyHolder) holder).tv_fb3c.setText(DateUtil.dateToString_HH_mm_ss(mList.get(position).getFB_3_C()));

        }
    }

    class MyHolder extends RecyclerView.ViewHolder {
        TextView tv_id;
        TextView tv_date;

        TextView tv_gb1;
        TextView tv_gb2;
        TextView tv_gb3;
        TextView tv_gb4;

        TextView tv_fb1a;
        TextView tv_fb1b;
        TextView tv_fb1c;

        TextView tv_fb2a;
        TextView tv_fb2b;
        TextView tv_fb2c;

        TextView tv_fb3a;
        TextView tv_fb3b;
        TextView tv_fb3c;



        public MyHolder(View itemView) {
            super(itemView);
            tv_id = (TextView) itemView.findViewById(R.id.item_id);
            tv_date = (TextView) itemView.findViewById(R.id.item_Date);

            tv_gb1 = (TextView) itemView.findViewById(R.id.tv_gb1);
            tv_gb2 = (TextView) itemView.findViewById(R.id.tv_gb2);
            tv_gb3 = (TextView) itemView.findViewById(R.id.tv_gb3);
            tv_gb4 = (TextView) itemView.findViewById(R.id.tv_gb4);

            tv_fb1a = (TextView) itemView.findViewById(R.id.tv_fb1a);
            tv_fb1b = (TextView) itemView.findViewById(R.id.tv_fb1b);
            tv_fb1c = (TextView) itemView.findViewById(R.id.tv_fb1c);

            tv_fb2a = (TextView) itemView.findViewById(R.id.tv_fb2a);
            tv_fb2b = (TextView) itemView.findViewById(R.id.tv_fb2b);
            tv_fb2c = (TextView) itemView.findViewById(R.id.tv_fb2c);

            tv_fb3a = (TextView) itemView.findViewById(R.id.tv_fb3a);
            tv_fb3b = (TextView) itemView.findViewById(R.id.tv_fb3b);
            tv_fb3c = (TextView) itemView.findViewById(R.id.tv_fb3c);
        }
    }

//    public void setData(ErrorInfoModel errorInfoModel){
//        mList.add(0,errorInfoModel);
//    }
}
